// API响应基础类型
export interface ApiResponse<T = any> {
  code: number
  message: string
  data: T
  timestamp: number
}

// 分页响应类型
export interface PageResponse<T = any> {
  records: T[]
  total: number
  size: number
  current: number
  pages: number
}

// 分页请求参数
export interface PageParams {
  current?: number
  size?: number
}

// 用户相关类型
export interface User {
  id: number
  username: string
  nickname?: string
  email?: string
  phone?: string
  avatar?: string
  status: number
  lastLoginTime?: string
  createdAt: string
  updatedAt: string
}

export interface LoginParams {
  username: string
  password: string
}

export interface LoginResponse {
  token: string
  user: User
}

// 站点相关类型
export interface Site {
  id: string | number
  name: string
  domain?: string
  logo?: string
  favicon?: string
  keywords?: string
  description?: string
  theme: string
  templatePrefix?: string
  modelId?: string | number
  parentId: string | number
  orderNum: number
  status: number
  mainsJson?: string
  clobsJson?: string
  customs?: Record<string, any>
  children?: Site[]
  model?: Model
  createdAt: string
  updatedAt: string
}

// 栏目相关类型
export interface Channel {
  id: string | number
  siteId: string | number
  parentId: string | number
  name: string
  alias?: string
  type: number
  channelModelId?: string | number
  articleModelId?: string | number
  channelTemplate?: string
  articleTemplate?: string
  image?: string
  linkUrl?: string
  targetBlank: number
  pageSize: number
  keywords?: string
  description?: string
  depth: number
  orderNum: number
  views: number
  status: number
  nav: number
  mainsJson?: string
  clobsJson?: string
  customs?: Record<string, any>
  children?: Channel[]
  parent?: Channel
  site?: Site
  channelModel?: Model
  articleModel?: Model
  createdAt: string
  updatedAt: string
}

export interface ChannelQueryParams extends PageParams {
  siteId?: number
  name?: string
}

// 文章相关类型
export interface Article {
  id: number | string
  siteId: number | string
  channelId: number | string
  userId: number | string
  title: string
  subtitle?: string
  fullTitle?: string
  alias?: string
  author?: string
  editor?: string
  source?: string
  image?: string
  video?: string
  audio?: string
  fileUrl?: string
  fileName?: string
  fileSize?: number
  articleTemplate?: string
  staticFile?: string
  allowComment: number
  withImage: number
  status: number
  publishDate?: string
  orderNum: number
  views: number
  comments: number
  downloads: number
  favorites: number
  ups: number
  downs: number
  customs?: Record<string, any>
  site?: Site
  channel?: Channel
  user?: User
  articleExt?: ArticleExt
  tags?: Tag[]
  createdAt: string
  updatedAt: string
}

export interface ArticleExt {
  id: number | string
  seoTitle?: string
  seoKeywords?: string
  seoDescription?: string
  content?: string
  markdown?: string
  imageListJson?: string
  fileListJson?: string
  mainsJson?: string
  clobsJson?: string
}

export interface ArticleQueryParams extends PageParams {
  siteId?: number
  channelId?: number
  status?: number
  title?: string
}

// 模型相关类型
export interface Model {
  id: number
  siteId?: number
  name: string
  type: number
  scope: number
  fieldsJson?: string
  orderNum: number
  status: number
  fields?: ModelField[]
  site?: Site
  createdAt: string
  updatedAt: string
}

export interface ModelField {
  name: string
  label: string
  type: string
  required?: boolean
  defaultValue?: any
  placeholder?: string
  options?: ModelFieldOption[]
  validation?: Record<string, any>
  settings?: Record<string, any>
}

export interface ModelFieldOption {
  value: string
  label: string
}

// 附件相关类型
export interface Attachment {
  id: number
  siteId: number
  userId: number
  name: string
  originalName: string
  path: string
  url: string
  size: number
  extension: string
  mimeType: string
  width?: number
  height?: number
  used: number
  site?: Site
  user?: User
  createdAt: string
}

export interface AttachmentQueryParams extends PageParams {
  siteId?: number
  name?: string
  mimeType?: string
}

// 标签相关类型
export interface Tag {
  id: number
  siteId: number
  name: string
  color?: string
  referCount: number
  site?: Site
  createdAt: string
  updatedAt: string
}
